package net.hn.hnms.biz.safety.water.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.hn.hnms.biz.api.feign.model.DataStateVo;
import net.hn.hnms.biz.api.safety.water.model.StateTrendVo;
import net.hn.hnms.biz.api.safety.water.model.WaterAlarmVo;
import net.hn.hnms.biz.api.safety.water.model.WaterTodayInfoVo;
import net.hn.hnms.biz.safety.water.domain.WaterQuality;
import net.hn.hnms.biz.safety.water.domain.dto.HolerealDataDto;
import net.hn.hnms.biz.safety.water.domain.dto.HydrologyDataDto;
import net.hn.hnms.biz.safety.water.domain.vo.*;
import net.hn.hnms.biz.safety.water.service.RiskMonitorWaterService;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 智呈物联 pan'sx
 * 2022/7/26 16:24
 * 1.0 version
 */
@RestController
@RequestMapping("/riskMonitor/flood")
@Api(value = "水害控制器", tags = {"水害监测"})
public class RiskMonitorWaterController {
    @Resource
    private RiskMonitorWaterService riskMonitorWaterService;

    @GetMapping("todayInfo")
    @ApiOperation("今日信息")
    @AutoSetMineCode
    public R<WaterTodayInfoVo> monitorInfo(@ApiParam(value = "煤矿编码") String mineCode) {
        WaterTodayInfoVo waterTodayInfoVo = riskMonitorWaterService.todayInfo(mineCode);
        return R.ok(waterTodayInfoVo);
    }

    @GetMapping("macropore")
    @ApiOperation("长观孔表格")
    @AutoSetMineCode
    public R<List<HolealVo>> stateTrend(@ApiParam(value = "煤矿编码") String mineCode) {
        List<HolealVo> list = riskMonitorWaterService.macropore(mineCode);
        return R.ok(list);
    }

    @GetMapping("hydrology")
    @ApiOperation("井下水文监测")
    @AutoSetMineCode
    public R<List<HydrologyVo>> realTime(@ApiParam(value = "煤矿编码") String mineCode) {
        List<HydrologyVo> list = riskMonitorWaterService.hydrology(mineCode);
        return R.ok(list);
    }

    @GetMapping("/waterQuality")
    @ApiOperation("水质分析")
    @AutoSetMineCode
    public R<WaterQuality> waterQuality(@ApiParam(value = "煤矿编码") String mineCode) {
        WaterQuality waterQuality = riskMonitorWaterService.waterQuality(mineCode);
        return R.ok(waterQuality);
    }

    @GetMapping("alarm")
    @ApiOperation("今日报警")
    @AutoSetMineCode
    public R<WaterAlarmVo> alarm(@ApiParam(value = "煤矿编码") String mineCode) {
        WaterAlarmVo waterAlarmVo = riskMonitorWaterService.alarm(mineCode);
        return R.ok(waterAlarmVo);
    }

    @GetMapping("alarmList")
    @ApiOperation("今日报警-弹窗列表")
    @AutoSetMineCode
    public R<List<AlarmTrendListVo>> alarmTrendList(@ApiParam(value = "输入报警类型（水温报警|水位报警|流量报警）") @RequestParam(value = "alarmType") String alarmType, @ApiParam(value = "煤矿编码") String mineCode) {
        List<AlarmTrendListVo> alarmTrendList = riskMonitorWaterService.alarmList(alarmType, mineCode);
        return R.ok(alarmTrendList);
    }

    @GetMapping("alarmTrend")
    @ApiOperation("水害报警动态")
    @AutoSetMineCode
    public R<StateTrendVo> alarmTrend(@ApiParam(value = "煤矿编码") String mineCode) {
        StateTrendVo stateTrendVo = riskMonitorWaterService.alarmTrend(mineCode);
        return R.ok(stateTrendVo);
    }

//    @GetMapping("alarmTrendList")
//    @ApiOperation("水害报警动态列表")
//    public R<List<AlarmTrendListVo>> alarmTrendList(){
//        List<AlarmTrendListVo> alarmTrendList = riskMonitorWaterService.alarmTrendList();
//        return R.ok(alarmTrendList);
//    }

    @GetMapping("indicator")
    @ApiOperation("测点统计")
    @AutoSetMineCode
    public R<PointStatisticsVo> indicator(@ApiParam(value = "煤矿编码") String mineCode) {
        PointStatisticsVo pointStatisticsVo = riskMonitorWaterService.indicator(mineCode);
        return R.ok(pointStatisticsVo);
    }

    @GetMapping("/dataQuery/holereal/pageList")
    @ApiOperation("数据查询(历史)-长观孔条件分页列表")
    @AutoSetMineCode
    public R<ResponsePage<HolerealDataVo>> dataQueryHolerealPageList(PageQuery pageQuery, HolerealDataDto holerealDataDto) {
        ResponsePage<HolerealDataVo> page = riskMonitorWaterService.dataQueryHolerealPageList(pageQuery, holerealDataDto);
        return R.ok(page);
    }

    @GetMapping("/dataQueryNow/holereal/pageList")
    @ApiOperation("数据查询(实时)-长观孔条件分页列表")
    @AutoSetMineCode
    public R<ResponsePage<HolerealDataVo>> dataQueryNowHolerealPageList(PageQuery pageQuery, HolerealDataDto holerealDataDto) {
        ResponsePage<HolerealDataVo> page = riskMonitorWaterService.dataQueryNowHolerealPageList(pageQuery, holerealDataDto);
        return R.ok(page);
    }

    @GetMapping("/dataQuery/holereal/pointName")
    @ApiOperation("数据查询-长观孔下拉框-测点名称")
    @AutoSetMineCode
    public R<List<String>> dataQueryHolerealPointName(@ApiParam(value = "煤矿编码") String mineCode) {
        List<String> list = riskMonitorWaterService.dataQueryHolerealPointName(mineCode);
        return R.ok(list);
    }

    @GetMapping("/dataQuery/hydrology/pageList")
    @ApiOperation("数据查询（历史）-井下水文条件分页列表")
    @AutoSetMineCode
    public R<ResponsePage<HydrologyDataVo>> dataQueryHydrologyPageList(PageQuery pageQuery, HydrologyDataDto holerealDataDto) {
        ResponsePage<HydrologyDataVo> page = riskMonitorWaterService.dataQueryHydrologyPageList(pageQuery, holerealDataDto);
        return R.ok(page);
    }

    @GetMapping("/dataQueryNow/hydrology/pageList")
    @ApiOperation("数据查询（实时）-井下水文条件分页列表")
    @AutoSetMineCode
    public R<ResponsePage<HydrologyDataVo>> dataQueryNowHydrologyPageList(PageQuery pageQuery, HydrologyDataDto holerealDataDto) {
        ResponsePage<HydrologyDataVo> page = riskMonitorWaterService.dataQueryNowHydrologyPageList(pageQuery, holerealDataDto);
        return R.ok(page);
    }

    @GetMapping("/dataQuery/hydrology/pointName")
    @ApiOperation("数据查询-井下水文下拉框-测点名称")
    @AutoSetMineCode
    public R<List<String>> dataQueryHydrologyPointName(@ApiParam(value = "煤矿编码") String mineCode) {
        List<String> list = riskMonitorWaterService.dataQueryHydrologyPointName(mineCode);
        return R.ok(list);
    }

    @GetMapping("/dataQuery/hydrology/pointLocaltion")
    @ApiOperation("数据查询-井下水文下拉框-监测地点")
    @AutoSetMineCode
    public R<List<String>> dataQueryHydrologyPointLocaltion(@ApiParam(value = "煤矿编码") String mineCode) {
        List<String> list = riskMonitorWaterService.dataQueryHydrologyPointLocaltion(mineCode);
        return R.ok(list);
    }

    @GetMapping("getHolerealMaxTime")
    @ApiOperation("长管孔数据最新时间")
    public R<List<DataStateVo>> getHolerealMaxTime(String mineCode, String companyCode) {
        return R.ok(riskMonitorWaterService.getHolerealMaxTime(mineCode, companyCode));
    }

    @GetMapping("getPSLMaxTime")
    @ApiOperation("排水量数据最新时间")
    public R<List<DataStateVo>> getPSLMaxTime(String mineCode, String companyCode) {
        return R.ok(riskMonitorWaterService.getPSLMaxTime(mineCode, companyCode));
    }

    @GetMapping("getYSLMaxTime")
    @ApiOperation("涌水量数据最新时间")
    public R<List<DataStateVo>> getYSLMaxTime(String mineCode, String companyCode) {
        return R.ok(riskMonitorWaterService.getYSLMaxTime(mineCode, companyCode));
    }
}
